/*
*Juery图片轮播对象
*初始化函数 ImagesShow.init(imgBoxs,naviBoxs,options)
*imgBoxs:Juqery图片元素对象集合(必须)
*naviBoxs:Juqery图片切换按钮(可为空)
*options:配置文件对象{speend:图片切换时间,wait:图片切换间隔}(可为空按默认值)
*/
var ImagesShow={
	imgBoxs:[],
	naviBoxs:[],
	naviCurrentClass:"",
	imgIndex:0,
	imgCount:0,
	timeoutIndex:0,
	options:{speed:1000,wait:7000},
	init:function(imgBoxs,naviBoxs,options){
		this.imgBoxs=imgBoxs;
		this.imgCount=imgBoxs.size();
		/*图片只有一个不做动画效果*/
		if(this.imgCount==1) return;
		/*图片样式*/
		var i=this.imgCount;
		this.imgBoxs.each(function(){
			$(this).css({"position":"absolute","z-index":--i});
		})
		var n=0;
		this.naviBoxs=naviBoxs||$(" ");
		this.naviBoxs.each(function(){
			$(this).attr("index_n",n++);
		})
		this.naviBoxs.click(function(){
			clearTimeout(ImagesShow.timeoutIndex);
			ImagesShow.display($(this).attr("index_n"));
		});
		this.naviCurrentClass="indexCurrent";
		
		this.display();
	},
	display:function(index){
		var imgCount=this.imgCount;
		var imgIndex=index||this.imgIndex;
			imgIndex=parseInt(imgIndex);
		var options=this.options;
		/*切换导航*/
		this.naviBoxs.removeClass(this.naviCurrentClass);
		$(this.naviBoxs[imgIndex]).addClass(this.naviCurrentClass);
		/*切换图片*/
		if(imgIndex+1==imgCount){//平稳切换
			this.imgBoxs.eq(imgIndex).show();
		}else{
			this.imgBoxs.eq(imgIndex).fadeIn(options.speed);
		}
		this.imgBoxs.not(this.imgBoxs.eq(imgIndex)).fadeOut(options.speed);
		this.imgIndex=((imgIndex+1)==imgCount)?0:(imgIndex+1);
		this.timeoutIndex=setTimeout(function(){
			ImagesShow.display();
		},options.wait);
	}
}